<template>
	<view class="commodity" 
	:style="'flex-wrap:'+wrap+';'">
		<!--单个商品-->
		<view class="commodity-item" 
		v-for="(item,index) in dataCommodityList" 
		:key="index" 
		:style="'width: '+itemW+';'"
		@tap="goDetails">
			<image class="commodity-img" :src="item.imgUrl" :style="'height:'+bigH+';'"></image>
			<view class="commodity-content">
				<text class="commodity-name">
					{{item.name}}
				</text>
				<view>
					<text class="pprice">￥{{item.pprice}}</text>
					<text class="oprice">￥{{item.oprice}}</text>
				</view>
				<text class="discount">{{item.discount}}折</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			//商品数据
			dataCommodityList: Array,
			//宽度
			itemW: {
				type: String,
				default: "375rpx"
			},
			//高度
			bigH: {
				type: String,
				default: "375rpx"
			},
			//换行
			wrap: {
				type: String,
				default: "wrap"
			}
		},
		methods: {
			goDetails(){
				uni.navigateTo({
					url: "/pages/details/details"
				})
			}
		}
	}
</script>

<style scoped>
.commodity{
	display: flex;
}
.commodity-item{
	padding-bottom: 20rpx;
}
.commodity-img{
	width: 100%;
}
.commodity-content{
	text-align: center;
}
.commodity-name{
	overflow: hidden;
	text-align: center;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	color: #333333;
	word-break: break-all;
	padding: 6rpx 20rpx;
	font-size: 26rpx;
}
.oprice{
	text-decoration: line-through;
	font-size: 24rpx;
	color: #999999;
}
.discount{
	border-radius: 4rpx;
	border: 1px solid #FF3333;
	padding: 2rpx 10rpx;
	font-size: 20rpx;
	color: #FF3333;
}
</style>